<?php

class Admin extends Controller {

    function __construct() {
        parent::__construct();

        if (!UserAccess::checkLoggedin() || $_SESSION['admin'] == 0) { //If user is not logged in sent back to login page
            header('location: ' . URL . 'login');
            exit;
        }

        $this->view->js_desktop[0] = URL . 'public/js/jquery_min.js';
        $this->view->js_desktop[1] = URL . 'public/js/jquery_ui_min.js';
        $this->view->js_desktop[4] = URL . 'public/js/picklist.js';
        $this->view->js_desktop[5] = URL . 'public/js/slide.js';
        $this->view->js_desktop[6] = URL . 'public/js/equalheights.js';

        $this->view->css_desktop[0] = URL . 'public/css/default.css';
        $this->view->css_desktop[1] = URL . 'public/css/picklist.css';
        $this->view->css_desktop[2] = URL . 'public/css/slide.css';
     }

    function index() {
        if (UserAccess::GetMobileViewer())
            $this->view->render('mobile/login/index');
        else
            $this->view->render('desktop/admin/index');
    }
    
        
    function SetRoundStatus() {
        
        $RoundNr = $_POST['RoundNr'];
        $RoundStatus = $_POST['RoundStatus'];
        
        $this->model->UpdateRoundStatus($RoundNr, $RoundStatus);
        
        $this->view->render('desktop/admin/index');
    }
    
    function SetMatchResult() {
       $MatchNr = $_POST['MatchNr'];
        $MatchResult = $_POST['MatchResult'];
        
        $this->model->UpdateMatchResult($MatchNr, $MatchResult);
        
        $this->view->render('desktop/admin/index');          
    }
    
    function UpdateScore() {
        $this->model->UpdateScore();
        $this->view->render('desktop/admin/index');
        
    }

}
